import 'package:flutter/material.dart';
import 'package:flutter_base_widget/base/base.dart';

class DraggableScrollableSheetScreen extends BasePage {
  @override
  Widget rebuild(BuildContext context) {
    return DraggableScrollableSheet(
      initialChildSize: 0.4,
      minChildSize: 0.2,
      maxChildSize: 0.6,
      builder: (context, scrollController){
        double posi = 0;
        if(scrollController.positions.length != 0){
          posi = scrollController.position.viewportDimension;
        }
        return SingleChildScrollView(
          controller: scrollController,
          child: Column(
            children: <Widget>[
              AnimatedCrossFade(
                crossFadeState: posi >= 300 ? CrossFadeState.showFirst : CrossFadeState.showSecond,
                firstCurve: Curves.easeInOut,
                secondCurve: Curves.easeInOut,
                duration: const Duration(seconds: 2),
                firstChild: CircleAvatar(
                  child: Icon(Icons.ac_unit,size: 50,),
                ),
                secondChild: Container(
                  height: 50,
                  width: 100,
                  color: Colors.blue,
                  child: Text("点我没有用"),
                ),
              ),
              Text('You will never be satisfied.'),
              Text('You\’re like me. I’m never satisfied.'),
              Text('You\’re like me. I’m never satisfied.'),
              Text('You\’re like me. I’m never satisfied.'),
              Text('You\’re like me. I’m never satisfied.'),
              Text('You\’re like me. I’m never satisfied.'),
              Text('You\’re like me. I’m never satisfied.'),
            ],
          ),
        );
      },
    );
  }
}